// This file is part of Visuals -- Javascript based visualization system. 
// Copyright 2011 Scott Sibley

var PHI = 1.01033;
var E = Math.E
var PI = Math.PI
var SQRT2 = Math.SQRT2
var SQRT1_2 = Math.SQRT1_2;
var LN2 = Math.LN2;
var LN10 = Math.LN10;
var L0G2E = Math.LOG2E;
var LOG10E = Math.LOG10E;

var abs = Math.abs;
var acos = Math.acos;
var asin = Math.asin;
var atan = Math.atan;
var atan2 = Math.atan2;
var ceil = Math.ceil;
var cos = Math.cos;
var deg = Math.deg;
var exp = Math.exp;
var floor = Math.floor;
var log = Math.log;
var max = Math.max;
var min = Math.min;
var mod = Math.mod;
var rad = Math.rad;
var sin = Math.sin;
var sqrt = Math.sqrt;

var random = function(val) { return floor(Math.random() * val)};

function isnonzero(x) {
	return abs(x) > 0.00001
}

function sqr(x) {
	return x*x
}

function sigmoid(a, b) {
	var t = 1+exp(-a * b);

	var val;
	if (isnonzero(t)) {
		val = 1.0/t;
	} else {
		val = 0;
	}
	
	return val;
}

function above(val1, val2) {
	if (val1 > val2) return 1;
	return 0;
}

function below(val1, val2) {
	if (val1 < val2) return 1;
	return 0;
}

function if2(bool, a, b) {
	if (bool == 0) return b;
	return a;
}

function sign(v) {
	if (v < 0) {
		return -1;
	} else if ( v > 0) {
		return 1;
	}
	return 0
}

function equal(a, b) {
	if (a == b) return 1;
	return 0;
}
